package danceDoll;

import com.jme3.app.SimpleApplication;
import com.jme3.input.MouseInput;
import com.jme3.scene.Node;
import com.jme3.renderer.RenderManager;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * The Main Program. Loads the Initialize.java where all required Classes been loaded
 */
public class DanceDoll extends SimpleApplication {

    protected MouseInput mouse;
    protected float frameCount = 0;
    protected Initialize init;
    private static final Logger logger = Logger.getLogger(DanceDoll.class.getName());

    public static void main(String[] args) {
        // Nur Warnungen ausgeben
        logger.getLogger("").setLevel(Level.WARNING);
  
        DanceDoll app = new DanceDoll();
        app.setShowSettings(false);
        
        try {
            app.start();
        } catch(Exception ex) {
            System.out.println(ex.getMessage());
            app.destroy();
            throw new RuntimeException(ex);
        }
    }

    @Override
    public void start(JmeContext.Type contextType) {
        
        AppSettings settings = new AppSettings(true);
        settings.setResolution(1000, 600);
        settings.setFrameRate(50);
        settings.setTitle("Dance Doll Delta V. 1");
        settings.setSamples(0); // Kantenglaettung
        settings.setVSync(true); // Enagle VSync
        setSettings(settings);
        
        String os = System.getProperty("os.name").toLowerCase();
        if(os.indexOf("mac") <= 0) {
            //setDisplayStatView(false); // Hide Statistics
            //setDisplayFps(false); // Show FPS
        }
        this.setPauseOnLostFocus(false); // Disable break on lost Focus
                     
        super.start(contextType);
    }

    @Override
    public void simpleInitApp() {
        try {
            init = new Initialize(this, this.settings);
        } catch (IOException ex) {
            Logger.getLogger(DanceDoll.class.getName()).log(Level.SEVERE, null, ex);
        }
        flyCam.setMoveSpeed(18);
        flyCam.setEnabled(false);
    }

    /**
     * Returns the rootNode where all stuff is added to.
     * @return Main Node
     */
    public Node getRoot() {
        return rootNode;
    }
    
    /**
     * Retuns the Main Class "Initialize"
     * @return the Class Initialize
     */
    public Initialize getInitialize() {
        return init;
    }
    
    /**
     * called per each Frame, tpf contains rate between fps and animation. Calls the AnimationControl to Animate the model.
     * @param tpf TimesPerFrame
     */
    @Override
    public void simpleUpdate(float tpf) {
            this.init.simpleUpdate(tpf);
    }

    @Override
    public void simpleRender(RenderManager rm) {
    }
}
